package com.book.service;

import java.util.List;



import com.book.dao.ManagerDao;
import com.book.entity.Book;




public class ManagerService {
	ManagerDao md=new ManagerDao();
	//检验查询方法的
		public List<Book> findBookAll(){
			List<Book> list=md.findBookAll();
			return list;
		}
		
		public boolean addBook(Book b){
			if(!md.isExistId((b.getBook_name()))){
				md.addBook(b);
				return true;
			}else{
				System.out.println("此商品已存在");
				return false;
			}
			
		}
		
		public Book findBookById(String book_id){
			Book b=md.findBookById(book_id);
			return b;
		}
		public Book findBookByName(String name){
			Book b=md.findBookByName(name);
			return b;
		}
		
		 /* 
		  * 验证商品修改方法	
		  */
		 
		public boolean updateBook(Book b){
			if(md.isExistId(b.getBook_id())){
				md.updateBook(b);
				return true;
			}else{
				return false;
			}
		}
		
		 /*
		  * * 验证商品删除方法	
		  */
		 
		public boolean deleteBook(String book_id){
			if(md.isExistId(book_id)){
				
				md.deleteBookByid(book_id);
				return true;
			}else{
				return false;
			}
		}
		
}
